﻿@using BootstrapBlazor.Shared.Samples;
@inject IStringLocalizer<Foo> LocalizerFoo
@inject IStringLocalizer<LabelsEditorForm> Localizer

<div>
    <p>@((MarkupString)Localizer["LabelsEditorFormDescription1"].Value)</p>
    <GroupBox>
        <EditorForm Model="@Dummy" ShowLabel="false" RowType="RowType.Inline" ItemsPerRow="2">
            <FieldItems>
                <EditorItem @bind-Field="context.Hobby" Items="@Foo.GenerateHobbys(LocalizerFoo)">
                </EditorItem>
            </FieldItems>
        </EditorForm>
    </GroupBox>

    <p class="mt-3">@((MarkupString)Localizer["LabelsEditorFormDescription2"].Value)</p>
    <GroupBox>
        <EditorForm Model="@Dummy" RowType="RowType.Inline" ItemsPerRow="2">
            <FieldItems>
                <EditorItem @bind-Field="context.Hobby" Items="@Foo.GenerateHobbys(LocalizerFoo)">
                </EditorItem>
            </FieldItems>
        </EditorForm>
    </GroupBox>

    <p class="mt-3">@((MarkupString)Localizer["EditorFormLabelAlignRight"].Value)</p>
    <GroupBox>
        <EditorForm Model="@Dummy" ShowLabel="true" RowType="RowType.Inline" ItemsPerRow="2" LabelAlign="Alignment.Right">
            <FieldItems>
                <EditorItem @bind-Field="context.Hobby" Items="@Foo.GenerateHobbys(LocalizerFoo)">
                </EditorItem>
            </FieldItems>
        </EditorForm>
    </GroupBox>

    <p class="mt-3">@((MarkupString)Localizer["EditorFormLabelAlignCenter"].Value)</p>
    <GroupBox>
        <EditorForm Model="@Dummy" ShowLabel="true" RowType="RowType.Inline" ItemsPerRow="2" LabelAlign="Alignment.Center">
            <FieldItems>
                <EditorItem @bind-Field="context.Hobby" Items="@Foo.GenerateHobbys(LocalizerFoo)">
                </EditorItem>
            </FieldItems>
        </EditorForm>
    </GroupBox>
</div>

@code {
    [NotNull]
    private Foo? Dummy { get; set; }

    /// <summary>
    /// OnInitialized 方法
    /// </summary>
    protected override void OnInitialized()
    {
        base.OnInitialized();

        Dummy = Foo.Generate(LocalizerFoo);
    }
}
